package com.itheima.d3_stream;

import java.util.*;
import java.util.stream.Stream;

/*
        目标：掌握Stream流的创建。

        1 单列集合获取Stream流
        2 双列集合获取Stream流
        3 数组获取Stream流
        4 同一种类型多个数据获取Stream流
 */
public class StreamTest2 {
    public static void main(String[] args) {
        // 1、如何获取List集合的Stream流？
        List<String> names = new ArrayList<>();
        Collections.addAll(names, "张三丰","张无忌","周芷若","赵敏","张强");
        names.stream().forEach(s->System.out.println(s));
        System.out.println("----------------");
        HashMap<String, String> map = new HashMap<>();
        map.put("001", "张无忌");
        map.put("002", "赵敏");
        map.put("003", "周芷若");
        map.put("004", "张强");
        Set<Map.Entry<String, String>> entries = map.entrySet();
        entries.stream().forEach(s->{
            System.out.println(s.getKey() + "---" + s.getValue());
        });
        System.out.println("----------------");
        Set<String> strings = map.keySet();
        strings.stream().forEach(s->System.out.println(s));
        System.out.println("----------------");
        String[] names2={"举个两","荀彧","红孩儿"};
        Stream<String> stream = Arrays.stream(names2);
        stream.forEach(s->System.out.println(s));
        System.out.println("----------------");
        Stream<String> shsh = Stream.of("张无忌", "赵敏", "周芷若", "张强");
        shsh.forEach(s->System.out.println(s));


    }
}
